package edu.uta.shorthorn.news.ui;



import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;


public class Home extends TabActivity {
    /** Called when the activity is first created. */
	
	TabHost tabHost;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, News.class);
        spec = tabHost.newTabSpec("news").setIndicator("News", res.getDrawable(R.drawable.newsxml))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, Entertainment.class);
        spec = tabHost.newTabSpec("entertainment").setIndicator("Fun", res.getDrawable(R.drawable.entertainmentxml)).setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, Sports.class);
        spec = tabHost.newTabSpec("sports").setIndicator("Sports", res.getDrawable(R.drawable.sportxml)).setContent(intent);
        tabHost.addTab(spec);
        
       intent = new Intent().setClass(this, Opinion.class);
        spec = tabHost.newTabSpec("opinion").setIndicator("Opinion", res.getDrawable(R.drawable.opinionxml)).setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
    }
    
    public Context getContext()
    {
    	return this;
    }
    
    public boolean onCreateOptionsMenu(Menu menu){
    	MenuInflater mi= getMenuInflater();
    	mi.inflate(R.menu.mmenu, menu);
    	return true;
    }
    
    
    public boolean onPrepareOptionsMenu(Menu menu){
    	return true;
    	
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) { 
		switch (item.getItemId()) {
		case R.id.calendar:
			Intent youTubeIntent = new Intent(this, YouTube.class);
			startActivity(youTubeIntent);   
			break;
		}
		return true;
   }
}